public class num965 {
    boolean b = true;
    public boolean isUnivalTree(TreeNode root) {
        int val = root.val;
        dsf(root,val);
        return b;
    }

    private void dsf(TreeNode root, int val) {
        if(root == null) {
            return;
        }
        if(root.val != val) {
            b = false;
        }
        dsf(root.left,val);
        dsf(root.right,val);
    }
}
